package com.pn.taikao.mapper;

import com.pn.taikao.entity.Paper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface PaperMapper {
    int insert(Paper paper);

    int update(Paper paper);

    int deleteById(@Param("id") Long id);

    Paper selectById(@Param("id") Long id);

    List<Paper> selectByTeacherId(@Param("teacherId") Long teacherId);

    List<Paper> selectByCourseId(@Param("courseId") Long courseId);
    
    /**
     * 根据课程ID查询已发布的试卷
     */
    List<Paper> selectPublishedByCourseId(@Param("courseId") Long courseId);

    List<Paper> selectPage(@Param("name") String name,
                            @Param("teacherId") Long teacherId,
                            @Param("courseId") Long courseId,
                            @Param("offset") int offset,
                            @Param("limit") int limit);

    long count(@Param("name") String name,
               @Param("teacherId") Long teacherId,
               @Param("courseId") Long courseId);
    
    /**
     * 更新试卷状态
     */
    int updateStatus(@Param("id") Long id, @Param("status") String status);
}


